var dktp = {};

dktp.returnButton = [{html: '<a onclick="dktp.returnPage()" style="cursor:pointer;">返回<i class="fa fa-goback"></i></a>'}];

/*
* 页面跳转
* */
dktp.jumpPage = function(url, data, callBack) {
    dktp.page = mini.open({
        title: '',
        url: url,
        showModal: true,
        width: '100%',
        height: '100%',
        showHeader: false,
        allowResize: false,
        loadOnRefresh: true,       //true每次刷新都激发onload事件
        onload: function () {
            var iframe = this.getIFrameEl();
            if (iframe.contentWindow.setData) {
                iframe.contentWindow.setData(data);
            }
        },
	    ondestroy: function (action) {
            if (callBack) {
                callBack(action);
            }
	    }
    });
    dktp.page.max();
};
dktp.returnPage = function() {
    if (window.CloseOwnerWindow) {
        return window.CloseOwnerWindow();
    } else {
        window.close();
    }
};

/*dktp.callBack = function(action) {
	if(action.success == "true") {
		dktp.showTips(action.success,action.successMessage);
	} else {
		dktp.showTips(action.success,action.errorMessage);
	}
};*/

/**
 *
 */
dktp.showDialog = function(options,callBack) {
    options = options||{};
    options = jQuery.extend({
        title: "弹出",
        showMaxButton: true,     //显示最大化按钮
        showModal: true,
        width: 600,
        height: 400,
        loadOnRefresh: true,       //true每次刷新都激发onload事件
        onload: function () {
            var iframe = this.getIFrameEl();
            var data = options.parm;
            if (iframe.contentWindow.setData) {
                iframe.contentWindow.setData(data);
            }
        },
        
    },options);
    dktp.dialog = mini.open(options);
    if (options.content) {
        dktp.dialog.setBody(options.content);
    }
    if (options.maxSize && options.maxSize == true) {
        dktp.dialog.max();
    }
    return dktp.dialog;
};

dktp.closeDialog = function(action) {
    if (window.CloseOwnerWindow) {
        return window.CloseOwnerWindow(action);
    } else {
        window.close(action);
    }
};

dktp.execParent = function(name) {
    if (window.parent) {
        return window.parent.eval(name);
    }
    return null;
};

dktp.showTips = function(success, message) {
    var state = 'default';
    if (success) {
        state = 'success';
    } else {
        state = 'danger';
    }
    var content = message;
    mini.showTips({
        content: content,
        state: state,
        x: 'center',
        y: 'center',
        timeout: 3000
    });
};